package com.healthcloud.controller;

import com.healthcloud.entity.*;
import com.healthcloud.service.LogService;
import com.healthcloud.utils.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.*;

/**
 * 日志信息
 */
@Controller
@RequestMapping(value = "/log")
@ApiIgnore
public class LogController {

	@Autowired
    private LogService logService;

    @ApiIgnore
    @RequestMapping(value = "/toLogMgr",method=RequestMethod.GET)
    public String toLog(){
        return "newframe/logmgr";
    }

    @ApiIgnore
    @RequestMapping(value = "/searchLog")
    public @ResponseBody
    Map<String, Object>  searchLog(LogEntity bean, Model model, @ModelAttribute("pageParam")PageParam pageParam){
        List<LogEntity> list = logService.search(bean, pageParam);
        int count = logService.count(bean);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("dataList", list);
        map.put("iTotalRecords", count);
        map.put("iTotalDisplayRecords", count);
        map.put("sEcho", pageParam.getsEcho());
        return map;
    }

    @RequestMapping(value = "/n/searchLog")
    @ResponseBody
    public Integer test(String data){
        System.out.println(data);
        return 200;
    }
}
